package com.qf.vote.controller;

import com.qf.vote.entity.PhoneToken;
import com.qf.vote.service.impl.PhoneTokenServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/vote")
public class RedirectController {
    @Autowired
    PhoneTokenServiceImpl phoneTokenService;

    @RequestMapping("/voting")
    public String voting(String phone, String token, String name) {
        String voting = phoneTokenService.voting(phone,token, name);
        if (voting.equals("-1")) {

            return "redirect:vote/setToken";
        }
        return voting;
    }

}
